package com.dckxx.common.config;

import com.dckxx.common.constant.CommonEnum;
import com.fhs.trans.service.impl.DictionaryTransService;
import lombok.AllArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @author ck
 */
@Configuration
@AllArgsConstructor
public class TransDictionaryConfig {

    private final DictionaryTransService dictionaryTransService;

    @Bean
    public void refreshEnum(){
        CompletableFuture.runAsync(() -> {
            Map<String, Map<String, String>> mapList = CommonEnum.getMapList();
            mapList.forEach((key,map) -> dictionaryTransService.refreshCache(key,map));
        });
    }
}
